package ufrj.safcp.demo.imageprocessing;

import java.io.File;

import ufrj.safcp.tools.imageprocessing.ICardImageProcessor;
import ufrj.safcp.tools.imageprocessing.MatlabCardImageProcessor;
import ufrj.safcp.tools.imageprocessing.UnredableNumberException;

public class ImageProcessorDemo {

	private static String pathToImage;

	public static void main(String[] args) {
		
		ICardImageProcessor ip = MatlabCardImageProcessor.getInstance();

		pathToImage = "H:\\Ufrj\\pfc\\Cartoes\\diversos_identificados";
		
		File fileToImage = new File(pathToImage);
		
		
		ip.initialize(pathToImage);
		
		String[] list = fileToImage.list();

		for (int i = 0; i < list.length; i++) {
			Integer readNumber;
			try {
				readNumber = ip.readNumber(list[i]);
				System.out.println(readNumber);
				if (list[i].contains(readNumber.toString())){
					System.out.println("OK - " + readNumber);
				} else {
					System.out.println("Fail - File " + list[i] + " gives the number " + readNumber);
				}
			} catch (UnredableNumberException e) {
				System.out.println("Error for file " + list[i] + ": " + e.getMessage());
			}
		}
		

	}

}
